import { defineConfig,loadEnv  } from 'vite' 
import { resolve } from 'path'

// https://vitejs.dev/config/
export default ({ mode }) => defineConfig({
  publicDir:"src/public",
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true
      }
    }
  }, 
  build: {
    outDir:"dist",
    assetsDir:"less",
    lib: {
      entry: loadEnv(mode, process.cwd()).PROD?resolve(__dirname, 'src/main.js'):resolve(__dirname, 'index.html'),
      name: 'ChunEditor',
      // the proper extensions will be added
      fileName: 'ChunEditor'
    },
    rollupOptions: {
      // 确保外部化处理那些你不想打包进库的依赖
      external: ['less'],
      output: {
        // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量ChunEditor
        globals: {
          ChunEditor: 'ChunEditor'
        }
      }
    }
  }
})
 
 